package jpa4azure.type;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.Embedded;
import javax.persistence.Transient;


class Jpa4AzureAnnotations {

	

	public FieldContext[] getFields(Collection<Field> fields, Object o) {
		ArrayList<FieldContext> values = new ArrayList<FieldContext>();
		
		for (Field field : fields) {
			if (Key.class.isAssignableFrom(field.getType()))
				continue;
			else if (field.getType().isAssignableFrom(Collection.class))
				continue;
			else if (field.isAnnotationPresent(Transient.class))
				continue;
			else if (field.getType().isEnum())
				values.add(new EnumContext(o,field));
			else if (field.isAnnotationPresent(Embedded.class))
				values.add(new EmbeddedContext(o, field));
			else if (PrimitiveWrapper.isPrimitive(field.getType()))
				values.add(new FieldContext(o, field));
			else
				values.add(new CompoundFieldContext(o,field));
		}
		return values.toArray(new FieldContext[0]);
	}

}
